PROJECT( easygames )

CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
#

SET(PROJECT_VERSION "0.0.0.1")

SET(DOXYFILE_OUTPUT_DIR "doc/")

INCLUDE(FindSDL)
#INCLUDE(FindOpenGL)
#
IF(SDL_FOUND)
  MESSAGE("SDL Found")
  INCLUDE_DIRECTORIES(SDL_INCLUDE_DIR)
ELSE(SDL_FOUND)
  MESSAGE("SDL not found")
ENDIF(SDL_FOUND)

link_libraries (
  ${SDL_LIBRARY}
  ${SDLIMAGE_LIBRARY} # if using SDL_image, obviously
  SDLmain # Sadly not included in SDL_LIBRARY variable
  )

MACRO(GENERATE_DOCUMENTATION DOXYGEN_CONFIG_FILE)
  FIND_PACKAGE(Doxygen)
  SET(DOXYFILE_FOUND false)

  IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${DOXYGEN_CONFIG_FILE})
    SET(DOXYFILE_FOUND true)
  ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${DOXYGEN_CONFIG_FILE})

  STRING(REGEX REPLACE "([^.]+)[.]cmake$" "\\1.cfg" DOXYGEN_FILE ${DOXYGEN_CONFIG_FILE})

  IF( DOXYGEN_FOUND )
    IF( DOXYFILE_FOUND )
      # Add target
      CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${DOXYGEN_CONFIG_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/${DOXYGEN_FILE})
      ADD_CUSTOM_TARGET( doc COMMAND ${DOXYGEN_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/${DOXYGEN_FILE}" )

      # TODO Add .tag file and generated documentation to the list of files we must erase when distcleaning

      # Read doxygen configuration file
      FILE( READ ${CMAKE_CURRENT_SOURCE_DIR}/${DOXYGEN_FILE} DOXYFILE_CONTENTS )
      STRING( REGEX REPLACE "\n" ";" DOXYFILE_LINES ${DOXYFILE_CONTENTS} )
      # Parse .tag filename and add to list of files to delete if it exists
      FOREACH( DOXYLINE ${DOXYFILE_CONTENTS} )
        STRING( REGEX REPLACE ".*GENERATE_TAGFILE *= *([^\n]+).*" "\\1" DOXYGEN_TAG_FILE ${DOXYLINE} )
      ENDFOREACH( DOXYLINE ${DOXYFILE_CONTENTS} )

      #ADD_TO_DISTCLEAN( ${PROJECT_BINARY_DIR}/${DOXYGEN_TAG_FILE} )

      # Parse doxygen output doc dir and add to list of files to delete if it exists
      FOREACH( DOXYLINE ${DOXYFILE_CONTENTS} )
        STRING( REGEX REPLACE ".*OUTPUT_DIRECTORY *= *([^\n]+).*" "\\1" DOXYGEN_DOC_DIR ${DOXYLINE} )
      ENDFOREACH( DOXYLINE ${DOXYFILE_CONTENTS} )

      #ADD_TO_DISTCLEAN( ${PROJECT_BINARY_DIR}/${DOXYGEN_DOC_DIR} )
      #ADD_TO_DISTCLEAN( ${PROJECT_BINARY_DIR}/${DOXYGEN_DOC_DIR}.dir )
      
    ELSE( DOXYFILE_FOUND )
      MESSAGE( STATUS "Doxygen configuration file not found - Documentation will not be generated" )
    ENDIF (DOXYFILE_FOUND)
  ELSE (DOXYFILE_FOUND)
    MESSAGE(STATUS "Doxygen not found - Documentation will not be generated")
  ENDIF(DOXYGEN_FOUND)
ENDMACRO(GENERATE_DOCUMENTATION)
        
INCLUDE_DIRECTORIES(lib/actormanager lib/core lib/config lib/files lib/geometry lib/input lib/render lib/sound)

ADD_SUBDIRECTORY(lib)
ADD_SUBDIRECTORY(tests)
